package kr.hkit.androidcomplete01.ch07;

import kr.hkit.androidcomplete01.ch07.DrawBitmap.MyView;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;

public class OffScreen extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Myview vw = new Myview(this);
		setContentView(vw);
	}
	
	class Myview extends View{
		public Myview(Context context) {
			super(context);
		}
		
		public void onDraw(Canvas canvas){
			canvas.drawColor(Color.LTGRAY);
			Paint pnt = new Paint();
			
			Bitmap BackBit = Bitmap.createBitmap(300, 200, Bitmap.Config.ARGB_8888);
			Canvas offscreen = new Canvas(BackBit);
			offscreen.drawColor(Color.GREEN);
			pnt.setColor(Color.RED);
			
			for(int x = 0; x<300; x+=10){
				offscreen.drawLine(x, 0, 300-x, 200, pnt);
			}
			
			canvas.drawBitmap(BackBit, 10, 10,null);
		}
		
	}
}
